﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.Windows.Controls.Primitives;

namespace Program
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Brush cbColor;
        List<Adonem> Adonemek = new List<Adonem>();

        public MainWindow()
        {
            InitializeComponent();

            if (Convert.ToBoolean(Program.Properties.Resources.elsoInditas))
                new tulajdonosMegadasa().ShowDialog();

            lbTulajdonos.Content = Program.Properties.Settings.Default.tulajdonos;

            cbColor = cbDevizanem.Background;

            Adonemek.Add(new Adonem(1, "teszt1", 1111, 1, new DateTime(2012, 12, 31), 6));
            Adonemek.Add(new Adonem(2, "teszt2", 2222, 2, new DateTime(2012, 12, 31), 6));
            Adonemek.Add(new Adonem(3, "teszt3", 3333, 3, new DateTime(2012, 12, 31), 6));

            grAdonemek.DataContext = Adonemek;
        }

        private void tviUgyfelek_Selected(object sender, RoutedEventArgs e)
        {
            sbInformacio.Items.Clear();
            grUgyfelek.Visibility = Visibility.Visible;
            tbCegRovidNev.Focus();
            StatusBarItem panel1 = new StatusBarItem();
            panel1.Content = "0/0 ügyfél";

            StatusBarItem panel2 = new StatusBarItem();
            panel2.Content = "Aktuális ügyfél következő beadási határidejének dátuma: ";

            StatusBarItem panel3 = new StatusBarItem();
            panel3.Content = "Aktuális ügyfél állapota: Szerkeztés alatt";

            sbInformacio.Items.Add(panel1);
            sbInformacio.Items.Add(new Separator());
            sbInformacio.Items.Add(panel2);
            sbInformacio.Items.Add(new Separator());
            sbInformacio.Items.Add(panel3);
            
        }

        private void tviUgyfelek_Unselected(object sender, RoutedEventArgs e)
        {
            grUgyfelek.Visibility = Visibility.Hidden;
        }

        private void cbAlkalmazott_Checked(object sender, RoutedEventArgs e)
        {
            lbAlkalmazottakSzama.IsEnabled = nudAlkalmazottakSzama.Enabled = true;
        }

        private void cbAlkalmazott_Unchecked(object sender, RoutedEventArgs e)
        {
            lbAlkalmazottakSzama.IsEnabled = nudAlkalmazottakSzama.Enabled = false;            
        }

        private void wfhAdoszam_LostFocus(object sender, RoutedEventArgs e)
        {
            mtbKshSzam.Text = mtbAdoszam.Text.Substring(0,8);
            mtbKshSzam.Text = mtbKshSzam.Text + mtbAdoszam.Text.Substring(11);
        }

        private void tviBevallasok_Selected(object sender, RoutedEventArgs e)
        {
            grAdonemek.Visibility = Visibility.Visible;
        }

        private void tviBevallasok_Unselected(object sender, RoutedEventArgs e)
        {
            grAdonemek.Visibility = Visibility.Hidden;
        }

        private void tviLekerdezesek_Selected(object sender, RoutedEventArgs e)
        {

        }

        private void tbSzekhelyTelepules_TextChanged(object sender, TextChangedEventArgs e)
        {
            if ((sender as System.Windows.Controls.TextBox).Text.Equals("Budapest"))
                lbSzekhelyKerulet.IsEnabled = wfhSzekhelyKerulet.IsEnabled = true;
            else
                lbSzekhelyKerulet.IsEnabled = wfhSzekhelyKerulet.IsEnabled = false;
        }


        private void mtbAdoszam_GotFocus(object sender, EventArgs e)
        {
            MaskedTextBox mtb = sender as MaskedTextBox;
            mtb.BackColor = System.Drawing.Color.Yellow;
        }

        private void mtbAdoszam_LostFocus(object sender, EventArgs e)
        {
            MaskedTextBox mtb = sender as MaskedTextBox;
            mtb.BackColor = System.Drawing.Color.White;
        }

        private void nudTelephelyKerulet_GotFocus(object sender, EventArgs e)
        {
            NumericUpDown nud = sender as NumericUpDown;
            nud.BackColor = System.Drawing.Color.Yellow;
        }

        private void nudTelephelyKerulet_LostFocus(object sender, EventArgs e)
        {
            NumericUpDown nud = sender as NumericUpDown;
            nud.BackColor = System.Drawing.Color.White;
        }

        private void cbDevizanem_GotFocus(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.ComboBox cb = sender as System.Windows.Controls.ComboBox;
            cb.Background = Brushes.Yellow;
        }

        private void cbDevizanem_LostFocus(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.ComboBox cb = sender as System.Windows.Controls.ComboBox;
            cb.Background = cbColor;
        }

        private void tbNyugdijFolyosotasiPenztar_TextChanged(object sender, TextChangedEventArgs e)
        {

        }

        private void grUgyfelek_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            
        }

        private void mtbKshSzam_GotFocus(object sender, EventArgs e)
        {
            
        }

        private void dgAdonemek_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            new wpfAdatok("Devizanemek").ShowDialog();
        }

        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            new wpfAdatok("Irányítószámok").ShowDialog();
        }

        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            new wpfAdatok("Közterület jellegek").ShowDialog();
        }

        private void MenuItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            new wpfAdatok("Ügyfélkapuk").ShowDialog();
        }
    }
}
